<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <link rel="stylesheet" type="text/css" media="screen"
          href="../static/css/bootstrap.min.css">
    <script src="../static/js/axios.min.js"></script>
    <style>
        body {
            margin: 0;
            padding: 0;
            min-height: 100vh;
            background: linear-gradient(135deg, #009ffd, #0066ff);
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: 'Microsoft YaHei', sans-serif;
        }

        .login-container {
            background: white;
            padding: 40px;
            border-radius: 15px;
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
            width: 350px;
            text-align: center;
        }

        .login-title {
            font-size: 28px;
            color: #333;
            margin-bottom: 30px;
        }

        .input-group {
            width: 100%;
            margin: 15px 0;
        }

        .input-group input {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 8px;
            outline: none;
            font-size: 16px;
            transition: all 0.3s ease;
        }

        .input-group input:focus {
            border-color: #009ffd;
            box-shadow: 0 0 5px rgba(0, 158, 255, 0.3);
        }

        .login-btn {
            background: linear-gradient(45deg, #009ffd, #0066ff);
            color: white;
            border: none;
            padding: 12px 30px;
            border-radius: 8px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-top: 25px;
        }

        .login-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }

        .links {
            margin-top: 20px;
            font-size: 14px;
            color: #666;
        }

        .links a {
            color: #0066ff;
            text-decoration: none;
            margin: 0 10px;
        }
    </style>
</head>
<body>
<div class="login-container">
    <h2 class="login-title">欢迎登录</h2>
    <form>
        <div class="input-group">
            <input id="username" type="text" placeholder="用户名" required>
        </div>
        <div class="input-group">
            <input id="password" type="password" placeholder="密码" required>
        </div>
        <button id="dl" class="login-btn">登录</button>
        <div class="links">
            <a href="#">忘记密码？</a>
            <button type="button" onclick="location.href='/index/register.html'">注册</button>
        </div>
    </form>
</div>
</body>

<script>

        document.getElementById("dl").onclick = function () {
            const username = document.getElementById("username").value
            const password = document.getElementById("password").value

            axios.post('/user/login', {
                "username": username,
                "password": password
            }).then(function (response) {
                console.log(response);

                if (response.data== 'ok') {
                    alert('登录成功');
                    window.location = '/index/users.html';
                }else {
                    alert('登录失败');

                }

            });
        }
</script>
</html>
